#pragma once

class CSortOperate
{
public:
	static void PrintfArray(int* Array, int size)
	{
		for (int i = 0; i < size; i++)
		{
			cout << Array[i]<<" ";
		}
		cout << endl;
	}

	static void Swap(int& A, int& B)
	{
		int Temp = A;
		A = B;
		B = Temp;
	}

	/*
	
	*/
	static int* QuickSort(int* nums, int start, int end)
	{
		int l = start, r = end;
		int base = start;
		if (l >= r)
			return nullptr;

		while(l < r)
		{
			while (nums[base] <= nums[r] && l < r)
			{
				r--;
			}
			while (nums[base] >= nums[l] && l < r)
			{
				l++;
			}

			if (l < r)
			{
				Swap(nums[l], nums[r]);
			}
		}
		Swap(nums[base], nums[l]);

		QuickSort(nums, start, l - 1);
		QuickSort(nums, l + 1, end);

		return nums;
	}

	static void InsertionSort(int* Array, int size)
	{
		int index;
		for (index = 0; index < size - 1; index++)
		{
			int Temp = Array[index + 1];
			int j = index;
			while (j >= 0 && Temp < Array[j])
			{
				Array[j + 1] = Array[j];
				j--;
			}
			Array[j + 1] = Temp;
			PrintfArray(Array, size);
		}
	}
};

